<?php
/**
 *
 * @author 6611833@qq.com
 *        
 */
class mobileapi_rpc_info {
	function __construct($app) {
		$this->app = $app;
	}

	public function get_version($param){
		$version['android']['ver'] = $this->app->getConf('mobileapi_info.version_aver');
		$version['android']['down'] = $this->app->getConf('mobileapi_info.version_adown');
		$version['ios']['ver'] = $this->app->getConf('mobileapi_info.version_iver');
		$version['ios']['down'] = $this->app->getConf('mobileapi_info.version_idown');
            $version['android']['ismust'] = app::get('mobileapi')->getConf('mobileapi_info.version_aismust');
            $version['ios']['ismust'] = app::get('mobileapi')->getConf('mobileapi_info.version_iismust');
            $version['android']['info'] = app::get('mobileapi')->getConf('mobileapi_info.version_ainfo');
            $version['ios']['info'] = app::get('mobileapi')->getConf('mobileapi_info.version_iinfo');
		if(isset($version[$param['os']])){
			return $version[$param['os']];		
		}
		return $version;
	}
	
	public function get_about($param){
		$about['android']['qrcode'] = base_storager::image_path($this->app->getConf('mobileapi_info.a_about'));
		$about['ios']['qrcode'] = base_storager::image_path($this->app->getConf('mobileapi_info.i_about'));
		$about['link'] = kernel::base_url(1).'/wap';
		$about['service_tel'] = $this->app->getConf('mobileapi_info.service_tel');
		$about['wechat_account'] = $this->app->getConf('mobileapi_info.wechat_account');
		$about['weibo_account'] = $this->app->getConf('mobileapi_info.weibo_account');		
		return $about;
	}
	
	public function get_suggest_type($param){
		$suggest_type_str=$this->app->getConf('mobileapi_info.suggest_type');
		$suggest_type_arr=explode('#!!#',$suggest_type_str);
		return $suggest_type_arr;
	}
	
		//APP 注册协议接口更换 cyky begin 2015-11-07
	function license_content($param){
		$license= app::get('b2c')->getConf('b2c.register.setting_member_license');
		$fmt_license=array('bodys'=>array('content'=>$license));
		return $fmt_license; 
	}
	//APP 注册协议接口更换 end
	
	//APP 注册协议接口更换 cyky begin 2015-11-07
	function lv_description($param){
		$lv_description= app::get('b2c')->getConf('b2c.register.lv_description');
		$fmt_description=array('bodys'=>array('content'=>$lv_description));
		return $fmt_description; 
	}
	//APP 注册协议接口更换 end
	

	//APP 注册协议接口更换 cyky begin 2015-11-07
	function score_rule($param){
		$score_rule= app::get('b2c')->getConf('b2c.register.score_rule');
		$fmt_score_rule=array('bodys'=>array('content'=>$score_rule));
		return $fmt_score_rule; 
	}
	//APP 注册协议接口更换 end

        /**
     * 我收藏商品列表
     */
    public function favorite($param = array())
    {
        //return kernel::single('b2c_user_object')->get_member_id();
		$nPage = $param['n_page'] ? $param['n_page'] : 1;
		$page_size= $param['page_size'] ? $param['page_size'] : 10;
		$user_object=kernel::single('b2c_user_object');
		$member_id = isset($param['member_id']) ? $param['member_id'] : $user_object->get_member_id();
        $membersData = $user_object->get_members_data(array('members'=>'member_lv_id'),$member_id);
        
		$aData = @kernel::single('b2c_member_fav')->get_yts_fav($member_id,$membersData['members']['member_lv_id'],$nPage, $page_size);
        $aProduct = $aData['products']['items'];
		//return $aData['products']['items'];
		if($aProduct){
			foreach($aProduct as $k=>$v){
				$aProduct[$k]['image_default_url'] = base_storager::image_path($v['image_default_id'], 'm' );
				if($v['nostore_sell']){
					$aProduct[$k]['store'] = 999999;
					$aProduct[$k]['product_id'] = $v['spec_desc_info'][0]['product_id'];
				}else{
					foreach((array)$v['spec_desc_info'] as $value){
						$aProduct[$k]['product_id'] = $value['product_id'];
						$aProduct[$k]['spec_info'] = $value['spec_info'];
						$aProduct[$k]['price'] = $value['price'];
						if(is_null($value['store']) ){
							$aProduct[$k]['store'] = 999999;
							break;
						}elseif( ($value['store']-$value['freez']) > 0 ){
							$aProduct[$k]['store'] = $value['store']-$value['freez'];
							break;
						}else{
							$aProduct[$k]['store'] = false;
						}
					}
				}
			}
		}
		

		//if(isset($param['mode'])&&$param['mode']=='yts'){
		return $aProduct;
		//}

    }	
	

}

?>